package com.kotlin.android.api.bean

import android.os.Parcel
import android.os.Parcelable

/**
 * 创建者: zl
 * 创建时间: 2020/5/18 1:49 PM
 * 描述:
 */
data class UserInfo(var code: Int = 0,
                    var avaThuUrl: String? = "",
                    var avatarUrl: String? = "",
                    var birthDay: String? = "",
                    var bizCode: Int = 0,
                    var bizMsg: String? = "",
                    var isBind: Boolean = false,
                    var mobile: String? = "",
                    var nickName: String? = "",
                    var customLabel: String? = "",
                    var labelUrl: String? = "",
                    var sex: Int = 0,
                    var uid: String? = "",
                    var vipLeavel: String? = "",//弃用
                    var msg: String? = "",
                    var openId: String? = "",
                    var setBirthday: Boolean = true,//是否可以修改生日
                    var isNewUser: Boolean = false//是否是新用户
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readInt(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readInt(),
        parcel.readString(),
        parcel.readByte() != 0.toByte(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readInt(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readByte() != 0.toByte(),
        parcel.readByte() != 0.toByte()
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(code)
        parcel.writeString(avaThuUrl)
        parcel.writeString(avatarUrl)
        parcel.writeString(birthDay)
        parcel.writeInt(bizCode)
        parcel.writeString(bizMsg)
        parcel.writeByte(if (isBind) 1 else 0)
        parcel.writeString(mobile)
        parcel.writeString(nickName)
        parcel.writeString(customLabel)
        parcel.writeString(labelUrl)
        parcel.writeInt(sex)
        parcel.writeString(uid)
        parcel.writeString(vipLeavel)
        parcel.writeString(msg)
        parcel.writeString(openId)
        parcel.writeByte(if (setBirthday) 1 else 0)
        parcel.writeByte(if (isNewUser) 1 else 0)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<UserInfo> {
        override fun createFromParcel(parcel: Parcel): UserInfo {
            return UserInfo(parcel)
        }

        override fun newArray(size: Int): Array<UserInfo?> {
            return arrayOfNulls(size)
        }
    }
}